<?php
/**
 * Notes:
 * User: wudg <544038230@qq.com>
 * Date: 2024/2/23 15:39
 */

namespace App\Utils;


class AmountUtils
{
    /**
     * 分转换为元
     * @param int $amount
     * @return float
     */
    public static function fenToYuan($amount)
    {
        return number_format((float)sprintf("%.2f",bcdiv((string)$amount, '100', 2)),2,'.','');
    }


    /**
     * 元转换为分
     * @param $amount
     * @return float|int
     */
    public static function yuanTofen($amount)
    {
        return (int)bcmul((string)$amount, '100');
    }
}